/*! grunt-template-1.0.0  Generate by 2016-11-17*/
var About = {
	close:{}
};

var Archive = {
	slidedown: function() {
		var btnShow = $('.archive-btn-show');
		var hideContent = $('.archive-hide');
		//		btnShow.on("click", hideContent, function() {
		//			var index;
		//			index = $(btnShow).index($(this));
		//			console.info(index);
		//			hideContent.eq(index).slideDown();
		//		});
		var index;
		
		btnShow.click(function() {
			index = $(btnShow).index($(this));
			if(hideContent.eq(index).css('display') === 'none') {
				cleancss();
				cleancss2();
				keep();
				hideContent.eq(index).slideDown();
				
				
				
			} else {
			
				hideContent.eq(index).slideUp();
				cleancss2();
				
			}

		});

		function cleancss() {
			
			hideContent.slideUp();
			
		}   
		function cleancss2(){
			$('.archive-btn-show ').css({'color':''});
			$('.archive-btn-show i').css({
				'color': '',
				'transform': ''
			});
			$('.archive-left-list1 li').css('background','');
			hideContent.css({'background':'','z-index':'10'});
		}

		function keep() {
			$('.archive-btn-show ').eq(index).css({'color':'#449D44'});
			$('.archive-btn-show i').eq(index).css({
				'color': '#449D44',
				'transform': 'rotateZ(90deg)'
			});
			
			$('.archive-left-list1 li').eq(index).css('background','#F5F5F5');
			hideContent.eq(index).css({'background':'#F5F5F5','z-index':'15'});
		}
	}
};
var Bolg = {
 
};
var Show = {
	show: function() {
		var spot = $("#spot>li");
		var print = $(".container-show-box>img");
		var showBox = $(".container-show");
		var box = $(".container-show-box");
		var pageWrappwr = $("container-page-wrapper");
		var n = 1;
		detection();
		var aa = setInterval (switchs, 4000);
		spot.click(function (){
			clearInterval(aa);
			spot.removeClass("on");
			$(this).addClass("on");
			n=$(this).index(); 
			switchs();
			aa=setInterval(switchs , 4000);
		});
		function switchs() {
			for(var i = 0; i < spot.length; i++) {
				n === i ? spot.eq(i).addClass("on") : spot.eq(i).removeClass("on");
			}
			for(var j = 0; j < print.length; j++) {
				n === j ? print.eq(j).fadeIn(800) : print.eq(j).fadeOut(800);
			}
			n++;
			if(n > 3) {
				n = 0;
			}
		}
		function detection() {
			var winWidth = $(window).innerWidth();
			if(winWidth <= 768) {
				if(winWidth <=768 && winWidth > 750) {
					showBox.width(winWidth - (winWidth -750));
					box.width(winWidth * 4);
					box.css({
						"height": "auto"
					});
					print.width(winWidth);
				} else {
					showBox.width(winWidth-30);
					box.width(winWidth * 4-30);
					box.css({
						"height": "auto"
					});
					print.width(winWidth-30);
				}

			} else if(winWidth > 768 && winWidth <= 1024){
				showBox.width(750);
				box.width(3000).height(400);
				print.width(750);
				
			} else if(winWidth > 1024 && winWidth < 1250) {
				showBox.width(winWidth - 520);
				box.width(winWidth * 4 - 520);
				box.css({
					"height": "auto"
				});
				print.width(winWidth - 520);
			} else if(winWidth >= 1250) {
				showBox.width(750);
				box.width(3000).height(400);
				print.width(750);
			}
		}
		$(window).resize(function() {
			detection();
		});
	}
};
var common = {
	// 属性 
	version: 1,
	a: '1234',
	// 方法
	test: function() {
		console.info(common.version);
	},
	close: function() {
		$('.close').click(function() {
			$('#DelWarning').hide();
		});
	},
	search: function(e) {
		var a = false;
		$('#search-input').hide();
		$('.search-icon').click(function() {
			a = false;
			stopEvent(event);
			$('#search-input').show().focus();
			$('#search-submit').css({
				"display": "block"
			});
			$('.header-search').addClass("active-search");
		});
		$('#search-input').blur(function() {
			$('body').click(function() {
				a = true;
				if(a) {
					a = false;
					$('#search-input').hide();
					$('#search-submit').css({
						"display": "none"
					});
					$('.header-search').removeClass("active-search");
				}
			});
			$('#search-submit').click(function() {
				a = false;
				stopEvent(event);
			});
			$('#search-input').click(function() {
				a = false;
				stopEvent(event);
			});
		});

		function stopEvent(event) { //阻止冒泡事件
			//取消事件冒泡
			//若省略此句，下面的e改为event，IE运行可以，但是其他浏览器就不兼容
			//grunt 会报错。。
			//var e = arguments.callee.caller.arguments[0] || event;
			
			if(event && event.stopPropagation) {
				// this code is for Mozilla and Opera
				event.stopPropagation();
			} else if(window.event) {
				// this code is for IE
				window.event.cancelBubble = true;
			}
		}
	}, 
	bar: function() {
		$(window).resize(function() {
			if($(window).width() >= 1024) {
				$('#toggle-icon .fa-bars').hide();
				$('#toggle-icon .fa-times').show();
				$('.nav-list').show();
			} else {
				$('#toggle-icon .fa-times').hide();
				$('#toggle-icon .fa-bars').show();
				$('.nav-list').hide();
			}
		});
		$('#toggle-icon .fa-bars').click(function() {
			$('#toggle-icon .fa-bars').hide();
			$('#toggle-icon .fa-times').show();
			$('.nav-list').slideDown(300);
			$('.home-prev').hide();
		});
		$('#toggle-icon .fa-times').click(function() {
			$('#toggle-icon .fa-times').hide();
			$('#toggle-icon .fa-bars').show();
			$('.nav-list').slideUp(300);
			$('.home-prev').show();
		});

	}
};
var ContactUs = {
	
};
var InputFocus ={
 	focused : function (){
 		$("input:gt(1)").focus(function (){
 			$(this).css({"outline": "#449D44 solid 1px"});
 		}).blur(function (){
 			$(this).css({"outline": "none"});
 		});
 		$("textarea").focus(function (){
 			$(this).css({"outline": "#449D44 solid 1px"});
 		}).blur(function (){
 			$(this).css({"outline": "none"});
 		});
 	}
};

var indexblog = {

	focus: function() {
		var photoBox = $("#index-blog-photo-container");
		var photoList = $("#index-blog-photo-container a img");
		var btnChange = $("#index-blog-photo-container .btn-change li");
		
		var index = 0;
		var id;
		btnChange.click(function() {
			index = $(this).index();
			change();

		});

		function autochange() {
			change();
			index++;
			if(index > 3) {
				index = 0;

			}
		}
		autochange();
		id = setInterval(autochange, 4000);

		function change() {
			btnChange.removeClass('active');
			btnChange.eq(index).addClass('active');
			photoList.hide();
			photoList.eq(index).fadeIn(800);
		}
		photoBox.hover(function() {
			clearInterval(id);
		}, function() {
			id = setInterval(autochange, 4000);
		});

		
		
		$(window).resize(function() {
			 
			var bodywidth = $(window).width();
			var cloon=$('#cloon').width();
			if(bodywidth<760){
				photoBox.css('width','"'+bodywidth+'"');
				photoBox.css('height','auto'); 
				
			}
		});

	}
};

//var $ = window.$;
//
//
//var indexblog = {
//	focus: function() {
//		var photoBox = $("#index-blog-photo-container");
//		var photoList = $(".pho");
//		var btnChange = $(".bc");
//		var index = 0;
//		var id;
//		btnChange.click(function() {
//			index = $(this).index();
//			change();
//
//		});
//
//		function autochange() {
//			change();
//			index++;
//			if(index > 3) {
//				index = 0;
//
//			}
//		}
//		autochange();
//		id = setInterval(autochange, 4000);
//
//		function change() {
//			btnChange.removeClass('active');
//			btnChange.eq(index).addClass('active');
//			photoList.css({
//				'filter': 'alpha(opacity = 0)',
//				'-moz-opacity': '0',
//				'-khtml-opacity': '0',
//				'opacity': '0',
//				'transition': '0.2s'
//			});
//			photoList.eq(index).css({
//				'filter': 'alpha(opacity = 100)',
//				'-moz-opacity': '1',
//				'-khtml-opacity': '1',
//				'opacity': '1',
//				'transition': '0.2s'
//			});
//		}
//		photoBox.hover(function() {
//			clearInterval(id);
//		}, function() {
//			id = setInterval(autochange, 4000);
//		});
//
//	}
//};

var home = {
	// 属性
	// 方法
	search: function(e) {
		var a = false;
		$('.search-icon').click(function() {
			a = false;
			stopEvent(event);
			$('#search-input').focus();
			$('#search-submit').css({
				"display": "block"
			});
			$('.header-search').addClass("active-search");
			$('.search-icon').css({"color":"#666262"});
		});
		$('#search-input').blur(function() {
			$('body').click(function() {
				a = true;
				if(a) {
					a = false;
					$('#search-submit').css({
						"display": "none"
					});
					$('.header-search').removeClass("active-search");
					$('.search-icon').css({"color":"#fff"});
				}
			});
			$('#search-submit').click(function() {
				a = false;
				stopEvent(event);
			});
			$('#search-input').click(function() {
				a = false;
				stopEvent(event);
			});
		});

		function stopEvent(event) { //阻止冒泡事件
			//取消事件冒泡
			//若省略此句，下面的e改为event，IE运行可以，但是其他浏览器就不兼容
			//grunt 会报错。。
			//var e = arguments.callee.caller.arguments[0] || event;
			
			if(event && event.stopPropagation) {
				// this code is for Mozilla and Opera
				event.stopPropagation();
			} else if(window.event) {
				// this code is for IE
				window.event.cancelBubble = true;
			}
		}
	}, 
	init: function() {
		var Img = $('#imgRund .img-boxs img');
		var buttons = $('#imgRund .content .home-prev');
		var points = $('#points li');
		var Imgsize = Img.size();
		var index = 0;
		var autoStart = setInterval(autoshow, 3000);
		function change(index) {
			points.removeClass('prevous-active');
			points.eq(index).addClass('prevous-active');
			Img.eq(index).siblings().animate({
				opacity: 0
			}, 1000);
			Img.eq(index).animate({
				opacity: 1
			}, 1000);
		}

		function autoshow() {
			index++;
			if(index <= Imgsize - 1) {
				change(index);
			} else {
				index = 0;
				change(index);
			}
		}
		points.click(function(){
			clearInterval(autoStart);
			$(this).addClass('prevous-active');
			index = $(this).index();
			change(index);
		});
		$('#next').click(function() {
			clearInterval(autoStart);
			index++;
			if(index > Imgsize - 1) {
				index = 0;
				change(index);
			}
			change(index);
		});
		$('#prev').click(function() {
			clearInterval(autoStart);
			index--;
			if(index < 0) {
				index = Imgsize - 1;
			}
			change(index);
		});
		

		function clearInt() {
			$(".content").mouseover(function() {
				clearInterval(autoStart);
			});
		}

		function setInt() {
			$(".content").mouseout(function() {
				autoStart = setInterval(autoshow, 3000);
			});
		}
		clearInt();
		setInt();
	}
};
var OtherPages = {
	
};

var Portfolio = {
	
	
};

var Services = {
	topp: function() {
		$('#reTop').click(function() {
			var id = setInterval(function() {
				var scrollTop = $(document).scrollTop();
				var speed = scrollTop / -4;
				scrollBy(0, Math.floor(speed));
				if(scrollTop <= 0) {
					clearInterval(id);
				}
			}, 30);
		});

		$(window).scroll(function() {
			var reTop = $('#reTop');
			var scrollTop = $(document).scrollTop();
			var screenHeight = $(window).height();
			if(scrollTop >= (screenHeight / 2)) {
				reTop.show();
			} else {
				reTop.hide();
			}
		});
	}

};